﻿@page "/usercenter"
@attribute [TabItemOption(Text = "个人中心")]

<AuthorizeView Context="context">
    <Authorized>
        <Row ItemsPerRow="ItemsPerRow.Three">
            <Card HeaderText="个人信息">
                <BodyTemplate>
                    <ValidateForm Model="@InfoCenter" OnFieldValueChanged="@OnFiledChanged">
                        <div class="row g-3">
                            <div class="col-12">
                                <BootstrapInput @bind-Value="@InfoCenter!.User_Ip" IsDisabled="true" style="border:none;" />
                            </div>
                            <div class="col-12">
                                <BootstrapInput @bind-Value="@InfoCenter.User_Address" IsDisabled="true" style="border:none;" />
                            </div>
                            <div class="col-12">
                                <BootstrapInput @bind-Value="@InfoCenter.User_Name" />
                            </div>
                            <div class="col-12">
                                <BootstrapInput @bind-Value="@InfoCenter!.User_Account" IsDisabled="true" style="border:none;" />
                            </div>
                            <div class="col-12">
                                <BootstrapInputGroup class="mt-2">
                                    <BootstrapInput @bind-Value="@InfoCenter.User_Phone" PlaceHolder="输入手机号" />
                                    <BootstrapInputGroupLabel DisplayText="验证码" />
                                    <BootstrapInput @bind-Value="@InfoCenter.User_Phone_Code" PlaceHolder="输入手机验证码"/>
                                    <CountButton Count="60"  Color="Color.Primary" Icon="fas fa-fw fa-comment-dots" OnClick="SendPhoneCode"></CountButton>
                                </BootstrapInputGroup>
                            </div>
                            <div class="col-12">
                                <BootstrapInputGroup class="mt-2">
                                    <BootstrapInput @bind-Value="@InfoCenter.User_Email" PlaceHolder="输入邮箱" />
                                    <BootstrapInputGroupLabel DisplayText="验证码" />
                                    <BootstrapInput @bind-Value="@InfoCenter.User_Email_Code" PlaceHolder="输入邮箱验证码" />
                                    <CountButton Count="60"  Color="Color.Primary" Icon="fas fa-fw fa-envelope" OnClick="SendEmailCode"></CountButton>
                                </BootstrapInputGroup>
                            </div>
                            <div class="col-12">
                                <Button ButtonType="ButtonType.Button" Color="Color.Danger" Icon="fas fa-fw fa-key" Text="修改密码"
                                        OnClick="PasUpdModal"/>
                                <Button ButtonType="ButtonType.Submit" Icon="fa-fw fa-solid fa-floppy-disk" Text="保存个人信息" IsAsync="true" OnClick="UpdUserInfo"   IsDisabled="saveUserbtndis" />
                            </div>
                        </div>
                    </ValidateForm>
                </BodyTemplate>
            </Card>
            <Card HeaderText="消息通知">
                <HeaderTemplate>
                    <Widget></Widget>
                </HeaderTemplate>
                <BodyTemplate>
                           @for (var index = 0; index < 10; index++)
                               {
                                   <a class="d-flex align-items-center" style=" height: 30px;" href="#" @onclick:preventDefault>
                                       <i class="fa fa-users text-primary"></i>
                                       <div class="ms-2">2023/08/18 PM 15:20 您有一个未处理的消息</div>
                                   </a>
                               }
                </BodyTemplate>
            </Card>
            <Card HeaderText="最新资讯">
                <BodyTemplate>
                    <Card IsShadow="true" HeaderText="计划推出">
                        <BodyTemplate>
                            <Alert Icon="fa-solid fa-circle-check" Color="Color.Success" ShowShadow="true">代码生成基础版</Alert>
                            <Alert Icon="fa-solid fa-circle-check" Color="Color.Success" ShowShadow="true">日志管理</Alert>
                            <Alert Icon="fa-solid fa-circle-question" Color="Color.Primary" ShowShadow="true">登陆界面主界面美化</Alert>
                            <Alert Icon="fa-solid fa-circle-check" Color="Color.Primary" ShowShadow="true">个人中心</Alert>
                            <Alert Icon="fa-solid fa-circle-question" Color="Color.Info" ShowShadow="true">系统资源权限验证</Alert>
                            <Alert Icon="fa-solid fa-circle-question" Color="Color.Info" ShowShadow="true">发送邮件丶短信</Alert>
                            <Alert Icon="fa-solid fa-circle-question" Color="Color.Info" ShowShadow="true">多因子登陆</Alert>
                            <Alert Icon="fa-solid fa-circle-question" Color="Color.Info" ShowShadow="true">实时通讯</Alert>
                            <Alert Icon="fa-solid fa-circle-question" Color="Color.Info" ShowShadow="true">单客户端登陆</Alert>
                        </BodyTemplate>
                    </Card>
                </BodyTemplate>
            </Card>
        </Row>

        <Modal @ref="PasModal">
            <ModalDialog Title="修改密码" IsCentered="true" Size="Size.Medium ">
                <BodyTemplate>
                    <ValidateForm Model="@userInfoPas" @ref="PasFormref">
                        <div class="row g-3">
                            <div class="col-12">
                                <BootstrapPassword @bind-Value="@userInfoPas!.OldPassWord"
                                                                PlaceHolder="请输入原密码"
                                                   ValidateRules="UserDataRules"/>
                            </div>
                            <div class="col-12">
                                <BootstrapPassword @bind-Value="@userInfoPas!.NewPassWord" 
                                                   PlaceHolder="请设置你的新密码"
                                                   ValidateRules="UserDataRules"/>
                            </div>
                            <div class="col-12">
                                <BootstrapPassword @bind-Value="@userInfoPas!.NewPassWordTo"
                                                   PlaceHolder="请输入你刚刚设置的新密码"
                                                   ValidateRules="UserDataRules"/>
                            </div>
                        </div>
                    </ValidateForm>
                </BodyTemplate>
                <FooterTemplate>
                    <Button Text="确认修改" Icon="fas fa-fw fa-key" OnClick="@PasUpdAction" IsAsync="true"/>
                </FooterTemplate>
            </ModalDialog>
        </Modal>
    </Authorized>
    <NotAuthorized>
        Warning: Not authorized to login, please return to login page!
    </NotAuthorized>
</AuthorizeView>

@code {

}
